package com.example.library.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.library.entity.R;
import com.example.library.entity.TeachingForm;
import com.example.library.entity.Teachingquestions;
import com.example.library.service.impl.TeachingquestionsServiceImpl;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * ces
 * </p>
 *
 * @author zhaoyufei
 * @since 2023-08-07
 */
@RestController
@RequestMapping("/teachingquestions")
public class TeachingquestionsController {

    @Resource
    private TeachingquestionsServiceImpl service;

    @PostMapping("/getPage")
    public R<IPage<Teachingquestions>> getPage(@RequestBody TeachingForm teachingForm) {
        IPage<Teachingquestions> pages = service.getPage(teachingForm);
        return new R<>("200", "ok", pages);
    }

    @DeleteMapping("/{id}")
    public R deleteById(@PathVariable Integer id) {
        service.deleteById(id);
        return new R<>();
    }

    @PostMapping
    public R updateById(@RequestBody Teachingquestions teachingquestions) {
        service.updateById(teachingquestions);
        return new R<>();
    }

    @PutMapping
    public R add(@RequestBody Teachingquestions teachingquestions) {
        service.save(teachingquestions);
        return new R<>();
    }

}
